package com.woniu.lottery.entity;

import lombok.Data;

import java.time.LocalDateTime;

@Data
public class LotteryResult {
    /**
     * 抽奖结果状态
     */
    private LotteryResultStatus status;

    /**
     * 是否中奖
     */
    private boolean isWinner;

    /**
     * 奖品ID (未中奖时为null)
     */
    private Long prizeId;

    /**
     * 奖品名称
     */
    private String prizeName;

    /**
     * 奖品类型 (1-实物 2-虚拟 3-积分)
     */
    private Integer prizeType;

    /**
     * 奖品值 (如积分数量、优惠券码等)
     */
    private String prizeValue;

    /**
     * 结果消息 (用于前端显示)
     */
    private String message;

    /**
     * 抽奖记录ID
     */
    private Long recordId;

    /**
     * 抽奖时间
     */
    private LocalDateTime lotteryTime;

    // 快速创建成功结果的静态方法
    public static LotteryResult success(Long prizeId, String prizeName,
                                        Integer prizeType, String prizeValue) {
        LotteryResult result = new LotteryResult();
        result.setStatus(LotteryResultStatus.SUCCESS);
        result.setWinner(true);
        result.setPrizeId(prizeId);
        result.setPrizeName(prizeName);
        result.setPrizeType(prizeType);
        result.setPrizeValue(prizeValue);
        result.setMessage("参与成功！");
        return result;
    }

    // 快速创建未中奖结果的静态方法
    public static LotteryResult fail(String message) {
        LotteryResult result = new LotteryResult();
        result.setStatus(LotteryResultStatus.SUCCESS);
        result.setWinner(false);
        result.setMessage(message != null ? message : "很遗憾，未中奖");
        return result;
    }

    // 快速创建错误结果的静态方法
    public static LotteryResult error(LotteryResultStatus status, String message) {
        LotteryResult result = new LotteryResult();
        result.setStatus(status);
        result.setWinner(false);
        result.setMessage(message);
        return result;
    }
}
